# @Time : 2020/8/24 14:55
# @Author : Fioman 
# @Phone : 13149920693
import cv2 as cv
import numpy as np

canvas = np.zeros((300, 300, 3), dtype=np.uint8)
green = (0, 255, 0)
cv.line(canvas, (0, 0), (300, 300), green, thickness=1)
cv.imshow("CanvasLine", canvas)
cv.waitKey(0)

red = (0, 0, 255)
cv.line(canvas, (0, 300), (300, 0), red, thickness=3)
cv.imshow("CanvasLine", canvas)
cv.waitKey(0)

# 画一个矩形,知道矩形的对角线即可.
blue = (255, 0, 0)
cv.rectangle(canvas, (100, 100), (150, 150), blue, 1)
cv.imshow("canvas", canvas)
cv.waitKey(0)

# 画一个实心的纯白色的矩形
white = (255, 255, 255)
cv.rectangle(canvas, (200, 200), (250, 250), white, -1)
cv.imshow("canvas", canvas)
cv.waitKey(0)

canvas = np.zeros((500, 500, 3), dtype=np.uint8)
centerX, centerY = canvas.shape[1] // 2, canvas.shape[0] // 2
red = (0, 0, 230)
for r in range(0, 251, 25):
    cv.circle(canvas, (centerX, centerY), r, red, thickness=1)

cv.imshow("CanvasCircle", canvas)
cv.waitKey(0)


# 画一些颜色随机,半径随机的圆形
canvas = np.zeros((500,500,3),dtype=np.uint8)
for i in range(0,25):
    radius = np.random.randint(5,high=200)
    color = np.random.randint(0,high=256,size=(3,)).tolist()
    center = np.random.randint(0,high=500,size=(2,))
    cv.circle(canvas,tuple(center),radius,color,-1)

cv.imshow("Canvas",canvas)
cv.waitKey(0)





























